package com.ideal.manage.esms.controller.overview;

import com.alibaba.fastjson.JSONObject;
import com.ideal.manage.esms.service.overview.OverviewService2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 平台总览
 * Created By Dai On 2018-04-07
 */
@Controller
@RequestMapping("overview")
public class OverviewController  {
    private Logger logger = LoggerFactory.getLogger(OverviewController.class);

    @Autowired
    private OverviewService2 overviewService2;
    /**
     * 平台总览
     */
    @RequestMapping("overview")
    public void overviewPage(Model model){
        // 1. 平台规模 总用户数
        Long totalUsers = overviewService2.getTotalUsers();
        model.addAttribute("total_users", totalUsers);
        // 2. 平台性能 平均充放电效率
        Double averageChargeDischarge = overviewService2.getAverageChargeDischarge();
        model.addAttribute("average_charge_discharge", averageChargeDischarge);
        // 3. 平台性能 系统安全稳定运行
        Integer safeOperationDays = overviewService2.getSafeOperationDays();
        model.addAttribute("safe_operation_days", safeOperationDays);
        // 4. 平台效益
        JSONObject jsonObject = overviewService2.getPlatformBenefit();
        model.addAttribute("jsonObject", jsonObject);
        // 5. 中间的百度地图
        List<JSONObject> list = overviewService2.findProjectInfo();
        model.addAttribute("list", list);
    }

    /**
     * 平台规模 中 的饼状图
     * @return
     */
    @RequestMapping("platform_scale")
    @ResponseBody
    public List getPlatformScale() {
        return overviewService2.getPlatformScale();
    }

    /**
     * 转移电量曲线
     * @param type
     * @return
     */
    @RequestMapping("transfer_power")
    @ResponseBody
    public JSONObject transferPower(String type){
        return overviewService2.transferPower(type);
    }

}
